<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var objs = document.getElementsByName("id");
		var sign = 0;
		for(var i = 0; i < objs.length; i++){
			if(objs[i].value != '0' && objs[i].checked){
				sign = sign + 1;
			}
		}
		if(sign <= 0){
			alert("请选择邮件！");
			return false;
		}
		return true;
	}
	
	function viewInternalMail(id){
		window.location.href = "./internalMailbox.do?action=viewInternalMail&id="+id+"&sign=2";
		window.location.target = "nEamilFrame";
	}

	function addInternalEmail(){
		window.location.href = "./internalMailbox.do?action=preAddInternalMail&sign=2";
		window.location.target = "nEamilFrame";
	}
	
	function moveInternalMail(){
		if(checkForm()){
			var selectValue = document.getElementById("moveMailId").value;
			if(selectValue == '1'){
				document.internalOutboxForm.action = "./internalMailbox.do?action=moveInternalMailToWastebox&sign=2";
				document.internalOutboxForm.target = "main";
				document.internalOutboxForm.submit();
			}
		}
	}
	
	function deleteInternalMail(){
		if(checkForm()){
			document.internalOutboxForm.action = "./internalMailbox.do?action=deleteInternalMail&sign=2";
			document.internalOutboxForm.target = "main";
			document.internalOutboxForm.submit();
		}
	}
	
	function searchInternalEmail(){
		var subject = document.getElementById("subject");
		if(subject.value == ""){
			alert("请输入关键字!");
		}else{
			document.getElementById("sFlag").value = "1";
			document.internalOutboxForm.action = "./internalMailbox.do?action=internalOutbox";
			document.internalOutboxForm.target = "nEamilFrame";
			document.internalOutboxForm.submit();
		}
	}
	
	function pageCustomer(flag){
		document.internalOutboxForm.action = "./internalMailbox.do?action=internalOutbox&flag="+flag;
		document.internalOutboxForm.target = "nEamilFrame";
		document.internalOutboxForm.submit();
	}
	
	function initPage(){
		if("<c:out value='${result}'/>" == '2'){
			alert("邮件已转移到废件箱中！");
		}else if("<c:out value='${result}'/>" == '3'){
			alert("删除成功！");
		}
	}
-->
</script>
</head>
<body style="width: 100%" onload="initPage()">
<form name="internalOutboxForm" action="" method="post">
	<table class="table_title2">
		<tr>
			<td class="title_lab">发件箱</td>
		</tr>
		<tr>
			<td valign="bottom" class="a_tools" style="padding-left: 3px;height: 35px;">关键字：
				<input id="subject" name="subject" class="input_query" type="text" value="${subject}"/>
				<a class="search" href="javascript:searchInternalEmail();" title="查询" hidefocus="true">查询</a>
				<input id="sFlag" name="sFlag" type="hidden" value="${sFlag}"/>
				|
				将选中邮件：
				<select id="moveMailId" name="moveMailId">
					<!-- 
					<option>--------请选择--------</option>
					 -->
					<option value="1">移动到垃圾箱</option>
				</select>
				<a class="ok" href="javascript:moveInternalMail();" title="确定" hidefocus="true">确定</a>
				|
				<a class="add" href="javascript:addInternalEmail();" title="新增" hidefocus="true">新增</a>
				<a class="del" href="javascript:deleteInternalMail();" title="删除" hidefocus="true">删除</a>
			</td>
		</tr>
		<tr><td height="2"></td></tr>
		<tr>
			<td>
				<table class="table_style">
					<tr>
						<td class="title" width="8"></td>
						<td class="title" width="30"><input id="id" name="id" type="checkbox" value="0" onclick="checkAll('id')"/></td>
						<td class="title">邮件主题</td>
						<td class="title" width="12%">收件人</td>
						<td class="title" width="12%">发件时间</td>
					</tr>
					<c:forEach var="mail" items="${mails}">
					<tr onmouseover="onmousemoveChange(this,'img${mail.id}')" onmouseout="onmouseoutChange(this,'img${mail.id}')">
						<td height="16" width="8" align="right"><img id="img${mail.id}" src="./images/table_sign2.bmp"></td>
						<td><input id="id" name="id" type="checkbox" value="${mail.id}"/></td>
						<td align="left">
							<a href="javascript:viewInternalMail('${mail.id}');" title="${mail.subject}" target="nEamilFrame">
							<c:choose>
								<c:when test="${fn:length(mail.subject) > 26}">${fn:substring(mail.subject,0,26)}......</c:when>
								<c:otherwise>${mail.subject}</c:otherwise>
							</c:choose>
							</a>
						</td>
						<td>${mail.recipients}</td>
						<td><fmt:formatDate value="${mail.createDate}" pattern="yyyy-MM-dd"/></td>
					</tr>
					</c:forEach>
				</table>
			</td>
		</tr>
		<tr>
			<td align="left" valign="bottom">
				<!-- page -->
				<table id="tp" class="table_page">
					<tr>
						<td>&nbsp;&nbsp;
							<img src="./images/frist.bmp" onclick="pageCustomer(1)" alt="首页" style="vertical-align: middle;cursor: hand;">
							<img src="./images/last.bmp" onclick="pageCustomer(2)" alt="上一页" style="vertical-align: middle;cursor: hand;">&nbsp;
							<font color="red">${currentPage}</font>/${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;
							<img src="./images/next.bmp" onclick="pageCustomer(3)" alt="下一页" style="vertical-align: middle;cursor: hand;">
							<img src="./images/end.bmp" onclick="pageCustomer(4)" alt="末页" style="vertical-align: middle;cursor: hand;">
							共&nbsp;&nbsp;${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>	
</body>
</html>